#include <bits/stdc++.h>
using namespace std;
int s[2100], n, ans;
void add(int k, int ss = 0) { 
    while (k) { 
        ss |= (1 << (k % 10));
        k /= 10;
    }
    s[ss]++;
}
int count(int t) { return (t <= 1) ? 0 : ((t * (t - 1)) >> 1); }
int main() { 
    freopen("number.in", "r", stdin);
    freopen("number.out", "w", stdout);
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) add(i);
    for (int i = 2047; i; i--) if (s[i]) ans += count(s[i]);
    printf("%d\n", ans);
}
